# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import os
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from wx_insurance.settings import BASE_DIR
from common.models import Location

class User_WX(models.Model):
    #Not staff Not superuser
    User_Types = (
        (90, _("Administrator")),
        (20, _("Bussiness Agent")),
        (10, _("Common User")),
        (0, _("Not Registered Yet"))
    )
    User_WX_Gender = (
        (2, _("Female")),
        (1, _("Male")),
        (0, _("Secrect"))
    )
    # user = models.OneToOneField(User)
    location = models.ForeignKey(Location,null=True,blank=True)
    # wx_unionid = models.CharField(max_length=64,blank=True,unique=True,verbose_name="微信UnionID",help_text="")
    wx_openid = models.CharField(max_length=64,blank=False,unique=True,verbose_name="微信OpenID",help_text="")

    wx_gender = models.IntegerField(default=None,blank=True,verbose_name="性别",choices=User_WX_Gender,help_text="0：保密，2：女，1：男")
    wx_nickname = models.CharField(default=None,blank=True,max_length=256,verbose_name="微信昵称",help_text="")
    wx_avatarUrl = models.URLField(default=None,blank=True,verbose_name="微信头像",help_text="")

    wx_language = models.CharField(default=None,blank=True,max_length=256,verbose_name="语言",help_text="")
    wx_country = models.CharField(default=None,blank=True,max_length=256,verbose_name="国家",help_text="")
    wx_province = models.CharField(default=None,blank=True,max_length=256,verbose_name="省份",help_text="")
    wx_city = models.CharField(default=None,blank=True,max_length=256,verbose_name="城市",help_text="")

    type = models.IntegerField(default=0,verbose_name="用户类型",choices=User_Types,help_text="0：未注册，10：普通用户，20：业务员，90：管理员")
    create_time = models.DateTimeField(auto_now_add=True, null=True,verbose_name="创建时间",help_text="")
    # update_time = models.DateTimeField(auto_now_add=True, null=True,verbose_name="更新时间",help_text="")
    # session_key = models.DateTimeField(auto_now_add=True, null=True,verbose_name="Session_key",help_text="")
    # expires_in = models.DateTimeField(auto_now_add=True, null=True,verbose_name="Session失效时间",help_text="")

    class Meta:
        verbose_name_plural = '用户名单'
        verbose_name = '用户基本信息'

    def __str__(self):
        return "{0}".format(self.wx_openid)


class User_Agent(models.Model):
    User_Staus_Codes = (
        (99, _("Suspend")),
        (100, _("Normal")),
        (0, _("Not Approved Yet"))
    )
    User_Gender = (
        (100, _("Female")),
        (99, _("Male")),
        (0, _("Secrect"))
    )
    user_wx = models.ForeignKey(User_WX)
    #必填信息
    name = models.TextField(default="无名",blank=False,verbose_name="姓名",help_text="如何称呼您，代理必须填完整正确名字")
    gender = models.IntegerField(default=0,blank=False,verbose_name="性别",choices=User_Gender,help_text="0：保密，100：女，99：男")
    mobile = models.CharField(default="0",max_length=16,blank=False,unique=True,verbose_name="手机号",help_text="")

    company = models.TextField(blank=False,verbose_name="隶属公司",help_text="")
    photo = models.URLField(blank=False,verbose_name="照片",help_text="照片文件地址")
    #选填信息
    in_career = models.IntegerField(default=0,verbose_name="从业年份",help_text="")
    certificate_no = models.CharField(max_length=32,verbose_name="资格证书编号",help_text="")
    self_introduction = models.TextField(verbose_name="自我简介",help_text="")
    #基本属性
    status = models.IntegerField(default=0,verbose_name="用户状态",choices=User_Staus_Codes,help_text="0：未验证，100：正常，99：暂停")
    update_time = models.DateTimeField(auto_now_add=True, null=True,verbose_name="更新时间",help_text="")

class User_Customer(models.Model):
    User_Staus_Codes = (
        (99, _("Suspend")),
        (100, _("Normal")),
        (0, _("Not Approved Yet"))
    )
    Contact_Allow_Code = (
        (1, _("Allow")),
        (0, _("No Contact"))
    )
    User_Gender = (
        (100, _("Female")),
        (99, _("Male")),
        (0, _("Secrect"))
    )
    user_wx = models.ForeignKey(User_WX)
    #必填信息
    name = models.TextField(default="无名",blank=False,verbose_name="姓名",help_text="如何称呼您，代理必须填完整正确名字")
    gender = models.IntegerField(default=0,blank=False,verbose_name="性别",choices=User_Gender,help_text="0：保密，100：女，99：男")
    mobile = models.CharField(default="0",max_length=16,blank=False,unique=True,verbose_name="手机号",help_text="")

    requireType = models.CharField(default="我要投保",max_length=1024,verbose_name="需求类型",help_text="")
    requirements = models.TextField(verbose_name="需求",help_text="")
    contact_allow = models.IntegerField(default=1,verbose_name="允许联系",choices=Contact_Allow_Code,help_text="1：允许，0：不允许")
    #基本属性
    status = models.IntegerField(default=100,verbose_name="用户状态",choices=User_Staus_Codes,help_text="100：正常，99：暂停")
    update_time = models.DateTimeField(auto_now_add=True, null=True,verbose_name="更新时间",help_text="")



